<template>
  <div class="accessBox">
    <div class="line">
      <div class="th" style="flex: 1">场所位置</div>
      <div class="th" style="flex: 1">扫码时间</div>
      <div class="th" style="flex: 0.8">场所类型</div>
      <div class="th" style="flex: 1">场所名称</div>
    </div>
    <div class="table scroll" ref="table_query_access" id="table_query_access">
      <div class="tr" v-for="(item, index) in tableData" :key="index" ref="tableRef">
        <div style="flex: 1">
          {{ item.placeLocation }}
        </div>
        <div style="flex: 1">
          {{ item.scanTime }}
        </div>
        <div style="flex: 0.8" class="overLine">
          {{ item.placeType }}
        </div>
        <div style="flex: 1">
          {{ item.scanTime }}
        </div>
        <!-- <div style="flex: 0.5" class="overLine">
        {{ item.healthcodeStatus }}
      </div> -->
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'access',
  props: {
    param: {
      type: Array,
      default: () => [],
    },
  },
  watch: {
    param: {
      deep: true,
      immediate: true,
      handler: function (val) {
        if (val !== undefined) {
          this.tableData = val
        }
      },
    },
  },
  data() {
    return {
      tableData: [],
    }
  },
  mounted() {
    this.autoScroll()
  },
  methods: {
    autoScroll() {
      const el = this.$refs.table_query_access
      const elHeight = el.offsetHeight
      const sHeight = el.scrollHeight
      setInterval(() => {
        if (el.scrollTop < sHeight - elHeight) {
          el.scrollTop++
        } else {
          el.scrollTop = 0
        }
      }, 50)
    },
  },
}
</script>

<style lang="less" scoped>
.accessBox {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  .line {
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    height: 40px;
    font-size: 14px;
    color: #ffffff;
    text-align: center;

    .th {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  .table {
    flex: 1;
    width: 100%;
    overflow: hidden auto;
    margin-top: 16px;

    .tr {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      height: 56px;
      font-size: 14px;
      color: #ffffff;
      text-align: center;

      &:nth-child(odd) {
        background: rgba(19, 181, 177, 0.4);
      }

      .overLine {
        overflow: hidden;
        white-space: nowrap;
        word-break: break-all;
        word-wrap: break-word;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
      }
    }
  }
}
</style>
